package main

import (
	"fmt"
	"sync"
	"time"
)

var mutex sync.Mutex //互斥锁
func printer(str string) {
	mutex.Lock()         //加锁
	defer mutex.Unlock() //解锁
	for _, ch := range str {
		fmt.Printf("%c", ch)
		time.Sleep(time.Millisecond * 300)
	}
}
func user1() {
	printer("hello ")
}
func user2() {
	printer("world")
}
func main() {
	go user1()
	go user2()
	for {

	}
}
